package com.noreply.springlearning.async;

import org.springframework.core.task.SimpleAsyncTaskExecutor;
import org.springframework.scheduling.annotation.AsyncConfigurerSupport;
import org.springframework.stereotype.Component;

import java.util.concurrent.Executor;

/**
 * 修改默认的线程池的大小
 * 任务添加不进去 当前主线程也会阻塞
 * @author noreply
 * @description
 * @datetime 2022/5/5 16:23
 */
@Component
public class AsyncConfig extends AsyncConfigurerSupport {


    @Override
    public Executor getAsyncExecutor() {
        SimpleAsyncTaskExecutor executor = new SimpleAsyncTaskExecutor();
        executor.setConcurrencyLimit(1);
        return executor;
    }
}
